/**
 * Copyright [2010] Delta Air Lines, Inc. All Rights Reserved Access,
 * Modification, or Use Prohibited Without Express Permission of Delta Air
 * Lines.
 */
package com.delta.rafg.coredata;

import java.util.ArrayList;
import java.util.List;

/**
 * @author RAFG Development Team (D9785692)
 */
public abstract class AResponse extends AObject {

	/**
	 * Holds the value of serialVersionUID property.
	 */
	private static final long serialVersionUID = 9207744351713979288L;

	/**
	 * Holds the value of advisoryMessage property.
	 */
	private String advisoryMessage = "";

	/**
	 * Holds the value of errorCode property.
	 */
	private String errorCode = "";

	/**
	 * Holds the value of errorMessage property.
	 */
	private String errorMessage = "";

	/**
	 * Holds the value of request property.
	 */
	private ARequest request;

	private String sessionId;

	//private DebugInfo debugObject;

	// private List<String> dataSourceRequests;
	//				
	// private List<String> dataSourceResponses;
	
	/**
	 * Holds error messages.
	 */
	private List<String>            errorMessageList;

	/**
	 * This method is the access method for the <code>dataSourceResponse</code>
	 * property, which is of type <code>String</code>.
	 * 
	 * @return the current value of the <code>dataSourceResponse</code>
	 *         property.
	 */
	public String getDataSourceResponse() {

		return this.dataSourceResponse;
	}

	/**
	 * This method is the access method for the <code>debugObject</code>
	 * property, which is of type <code>DebugInfo</code>.
	 * 
	 * @return the current value of the <code>debugObject</code> property.
	 */
	public DebugInfo getDebugObject() {

		if (!this.getDebugInformation().isEmpty()) {
			this.getDebugInformation().get(0);
		}
		return null;
	}

	/**
	 * This method sets the value of the <code>debugObject</code> property,
	 * which is of type <code>DebugInfo</code>.
	 * 
	 * @param debugObject
	 *            - the new value of <code>debugObject</code> property.
	 */
	public void setDebugObject(DebugInfo debugObject) {

		this.getDebugInformation().add(debugObject);
	}

	/**
	 * This method sets the value of the <code>dataSourceResponse</code>
	 * property, which is of type <code>String</code>.
	 * 
	 * @param dataSourceResponse
	 *            - the new value of <code>dataSourceResponse</code> property.
	 */
	public void setDataSourceResponse(String dataSourceResponse) {

		this.dataSourceResponse = dataSourceResponse;
	}

	/**
	 * The data source response generated by the SOA invocation. This data
	 * source response is used by the debug views in the application to view the
	 * demand codes generated by the application.
	 */
	private String dataSourceResponse;

	/**
	 * This is a constructor of AResponse.java
	 */
	public AResponse() {

	}

	/**
	 * This is a constructor of AResponse.java
	 * 
	 * @param pRequest
	 */
	public AResponse(final ARequest pRequest) {

		setRequest(pRequest);
	}

	/**
	 * This method is the access method for the <code>advisoryMessage</code>
	 * property, which is of type <code>String</code>.
	 * 
	 * @return the current value of the <code>advisoryMessage</code> property.
	 */
	public String getAdvisoryMessage() {

		return advisoryMessage;
	}

	/**
	 * This method is the access method for the <code>errorCode</code> property,
	 * which is of type <code>String</code>.
	 * 
	 * @return the current value of the <code>errorCode</code> property.
	 */
	public String getErrorCode() {

		return errorCode;
	}

	/**
	 * This method is the access method for the <code>errorMessage</code>
	 * property, which is of type <code>String</code>.
	 * 
	 * @return the current value of the <code>errorMessage</code> property.
	 */
	public String getErrorMessage() {

		return errorMessage;
	}

	/**
	 * @return the request
	 */
	public ARequest getRequest() {

		return request;
	}

	/**
	 * @return the sessionId
	 */
	public String getSessionId() {
		return sessionId;
	}

	/**
	 * Returns true if this response instance was successful in processing the
	 * request.
	 */
	public boolean isSuccessful() {

		if (getErrorCode() != null && !"".equals(getErrorCode())) {
			return false;
		}

		if (getErrorMessage() != null && !"".equals(getErrorMessage())) {
			return false;
		}

		return true;
	}

	/**
	 * This method sets the value of the <code>advisoryMessage</code> property,
	 * which is of type <code>String</code>.
	 * 
	 * @param errorMessage
	 *            - the new value of <code>advisoryMessage</code> property.
	 */
	public void setAdvisoryMessage(final String advisoryMessage) {

		this.advisoryMessage = advisoryMessage;
	}

	/**
	 * This method sets the value of the <code>errorCode</code> property, which
	 * is of type <code>String</code>.
	 * 
	 * @param errorMessage
	 *            - the new value of <code>errorCode</code> property.
	 */
	public void setErrorCode(final String errorCode) {

		this.errorCode = errorCode;
	}

	/**
	 * This method sets the value of the <code>errorMessage</code> property,
	 * which is of type <code>String</code>.
	 * 
	 * @param errorMessage
	 *            - the new value of <code>errorMessage</code> property.
	 */
	public void setErrorMessage(final String errorMessage) {

		this.errorMessage = errorMessage;
	}

	/**
	 * @param request
	 *            the request to set
	 */
	public void setRequest(final ARequest request) {

		this.request = request;
	}

	/**
	 * @param sessionId
	 *            the sessionId to set
	 */
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}

	/**
	 * The data source request generated by the SOA invocation. This data source
	 * request is used by the debug views in the application to view the demand
	 * codes generated by the application.
	 */
	private String dataSourceRequest;

	public String getDataSourceRequest() {
		return dataSourceRequest;
	}

	public void setDataSourceRequest(String dataSourceRequest) {
		this.dataSourceRequest = dataSourceRequest;
	}

	/**
	 * The list of debug information for this response.
	 */
	private List<DebugInfo> debugInformation = new ArrayList<DebugInfo>();

	/**
	 * @return the debugInformation
	 */
	public List<DebugInfo> getDebugInformation() {
		return debugInformation;
	}
	
	/**
	 * Add a Debug information to this response.
	 */
	public void addDebug(DebugInfo debug){
		
		this.debugInformation.add(debug);
	}

	/**
	 * @param debugInformation the debugInformation to set
	 */
	public void setDebugInformation(List<DebugInfo> debugInformation) {
		
		this.debugInformation = debugInformation;
	}

/**
 * This method is the access method for the <code>errorMessageList</code> property, 
 * which is of type <code>List<String></code>.
 * @return the current value of the <code>errorMessageList</code>
 * property.
 */
	public List<String> getErrorMessageList() {

		if (this.errorMessageList == null) {
			errorMessageList = new ArrayList<String>();
		}
		return this.errorMessageList;
	}

/**
 * This method sets the value of the <code>errorMessageList</code> property,
 * which is of type <code>List<String></code>.
 * @param errorMessageList - the new value of <code>errorMessageList</code> property.
 */
public void setErrorMessageList(List<String> errorMessageList) {

				this.errorMessageList = errorMessageList;
}
}
